﻿@model NK.Mvc3.Models.StoreInputDetail
@using (Ajax.BeginForm("AjaxUpdate", "StoreInputDetail", null, new AjaxOptions
{
    HttpMethod = "POST",
    InsertionMode = InsertionMode.Replace,
    UpdateTargetId = "storeinputdetail-" + Model.ID
}, new { @id = "ajaxupdateform-" + Model.ID, }))
 {
    <table>
     <tr id="storeinputdetail-@Model.ID">

         <td>
             @Html.TextBox("dtupdateBarCode-" + @Model.ID, null, new
                                                                   {
                                                                       @class = "grid-textbox-text",
                                                                       Value = Model.ProductInfo.BarCode,
                                                                       onchange = "changeBarCode(this,'hdProductInfoID-" + Model.ID + "','dtupdatePOSDescription-" + Model.ID + "')"
                                                                   })
             @Html.ValidationMessage("dtupdateBarCode-" + @Model.ID)
             @Html.HiddenFor(model => model.ID)
        
             @Html.HiddenFor(model => model.StoreInputID, new {Value = Model.StoreInput.ID, id = "hdStoreInputID-" + Model.ID})
             @Html.ValidationMessageFor(model => model.StoreInputID)

             @Html.HiddenFor(model => model.ProductInfoID, new {id = "hdProductInfoID-" + Model.ID})
             @Html.ValidationMessageFor(model => model.ProductInfoID)
         </td>
    
         <td>
             @Html.TextBox("dtupdatePOSDescription-" + @Model.ID, null, new {@class = "grid-textbox-text", disabled = "disabled", Value = Model.ProductInfo.POSDescription})
         </td>
    
         <td>
             @Html.TextBoxFor(model => model.Quantity, new {@class = "grid-textbox-num"})
             @Html.ValidationMessageFor(model => model.Quantity)
         </td>
    
         <td>
             @Html.TextBoxFor(model => model.ExpireDate, new {@class = "grid-textbox-date"})
             @Html.ValidationMessageFor(model => model.ExpireDate)
         </td>
    
         <td>
             @Html.TextBoxFor(model => model.FreeQuantity, new {@class = "grid-textbox-num"})
             @Html.ValidationMessageFor(model => model.FreeQuantity)
         </td>
    
         <td>
             @Html.TextBoxFor(model => model.CostInput, new {@class = "grid-textbox-num"})
             @Html.ValidationMessageFor(model => model.CostInput)
         </td>
    
         <td>
             @Html.TextBoxFor(model => model.TotalCost, new {@class = "grid-textbox-num"})
             @Html.ValidationMessageFor(model => model.TotalCost)
         </td>
    
         <td>
             <input type="submit" value="OK" />
         </td>

     </tr>
     </table>
 }
    
<script type="text/javascript">
    $(function () {
        $.validator.unobtrusive.parse("#ajaxupdateform-@Model.ID");
        var html = $('#storeinputdetail-@Model.ID table tr').contents(); //.children('tr');
        $('#storeinputdetail-@Model.ID').replaceWith(html);
        //$.validator.unobtrusive.parse("#ajaxupdateform-@Model.ID input");
    });
</script>